#!/usr/bin/env python
# -*- coding: utf-8 -*-


from flask import Flask

app = Flask(__name__)

import config
#app.config.from_object(config.Config)
app.config.from_object(config.DevConfig)

if not app.debug:
    from logging.handlers import RotatingFileHandler
    import logging
    handler = RotatingFileHandler('flask.log', maxBytes=10000, backupCount=1)
    handler.setLevel(logging.INFO)
    app.logger.addHandler(handler)

@app.route('/')
def hello_world():
    return "Hello world"

from model import *
from api import site_index, site_link, pagerank, site, alexa
from extensions import restful_api

restful_api.add_resource(site_index.Greeting, "/greeting")
restful_api.add_resource(site_index.Index, "/api/1/site_index/<string:se>")
restful_api.add_resource(site_link.Link, "/api/1/site_link/<string:se>")
restful_api.add_resource(pagerank.PageRank, "/api/1/pagerank/id/<int:id>",
                                            "/api/1/pagerank")
restful_api.add_resource(site.SiteApi, "/api/1/site")
restful_api.add_resource(site.SiteInfo, "/api/1/site_info")
restful_api.add_resource(site.SiteBeian, "/api/1/site_beian")
restful_api.add_resource(alexa.AlexaApi, "/api/1/alexa")
